<template>
	<div class="ai-template-form-wrapper" :class="`${videoType}-${audioType}`">
		<el-form v-if="!isTaskIdChange" :model="form" :rules="rules" class="form-wraper" label-width="120px" label-position="center" ref="template">
			<!-- AI 播报话术输入框 -->
			<AiSpeak
				v-if="hasAiSpeak"
				:variableIcon="true"
				:label="hasAiSpeakRequired ? 'AI播报话术' : 'AI说'"
				placeholder="请输入AI客服播报的话术"
				:required="hasAiSpeakRequired"
				:value="form.aiSpeak"
				:video="form.aiSpeakVideo"
				:textArea="hasAiSpeakTextArea"
				interfaceCall
				@input="input"
				@clearVideo="clearVideo"
				:validateStatus="form.aiSpeakVideoValidate"
				prop="aiSpeak"
				:showDetail="showDetail"
				@onAddVariable="onAddVariable"
				@showVideoTable="showVideoTable"
			/>
			<!-- 卡证采集类型 -->
			<CardCollection
				:value="form.cardCollectionType"
				:identifyResult="form.identifyResult"
				:showDetail="showDetail"
				:cardCollectionOptions="getDefaultCardCollectionOptions()"
				v-if="getTalkId === 'cardCollection'"
				prop="cardCollectionType"
				@input="input"
				:openOCR="form.openOCR"
			/>
			<!-- 信息推送URL地址 -->
			<NormalInput
				v-if="hasRequestApi"
				:variableIcon="true"
				:label="'接口请求URL'"
				placeholder="请输入URL地址"
				:required="true"
				:value="form.informationRushurlAddress"
				@input="input"
				:showDetail="showDetail"
				prop="informationRushurlAddress"
				@onAddVariable="onAddVariable"
				@showVideoTable="showVideoTable"
			/>
			<!-- 阈值 -->
			<AiSpeak
				v-if="hasConfidence"
				:variableIcon="false"
				:label="'阈值'"
				placeholder="高于此数值，则可判断为真人"
				:required="true"
				:value="form.confidence"
				:minlength="1"
				:maxlength="3"
				:video="null"
				@input="input"
				prop="confidence"
				:showDetail="showDetail"
				@onAddVariable="onAddVariable"
				@showVideoTable="showVideoTable"
			/>
			<!-- 业务指令 -->
			<BusinessInstruct v-if="hasBusinessInstruct" :showDetail="showDetail" :businessInstruct="form.businessInstruct" @input="input" :prop="'businessInstruct'" />
			<!-- 内容推送,推送PDF，富文本，链接，视频 -->
			<SendContentsInput
				v-if="hasWordsSendContents"
				:showDetail="showDetail"
				:value="form.wordsSendContents"
				@input="input"
				@onAddVariable="onAddVariable"
				@chooseUserAttribute="chooseUserAttribute"
				:prop="'wordsSendContents'"
			/>
			<!-- 信息收集多选 -->
			<CollectVariableSelect v-if="hasWordsVariable" :showDetail="showDetail" :value="form.wordsVariable" @onChange="onChange" @input="input" prop="wordsVariable" />
			<!-- 接口下拉选择框，表单 || 业务场景 || 证言 -->
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'sendDeposition'"
				:required="true"
				:value="form.testimonyId"
				prop="testimonyId"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
			/>
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'sendForm'"
				:required="true"
				:value="form.formId"
				prop="formId"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
			/>
			<!-- 场景转接 -->
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'sceneTransfer'"
				:required="true"
				:value="form.bizSceneId"
				prop="bizSceneId"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:taskId="taskId"
			/>
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'sceneTransfer'"
				:required="false"
				:values="form.transferGroups"
				prop="transferGroups"
				typeSelect="skillGroup"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:bizSceneId="form.bizSceneId"
				:placeholder="form.bizSceneId ? '请选择要转接的技能组' : '请先选择要转接的业务场景'"
				:taskId="taskId"
			/>
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'collectShortVideo'"
				:required="true"
				:value="form.collectShortVideoTime"
				prop="collectShortVideoTime"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:listOptions="collectShortVideoTimes"
			/>
			<!-- 等待时长输入框 -->
			<AiSpeak
				v-if="hasWaitTime"
				:variableIcon="false"
				:label="getTalkId === 'nlp' ? '收音等待时长' : '等待时长'"
				:placeholder="getTalkId === 'interfaceCall' ? '调取接口的等待时长，最小等待时长1000ms' : '请输入等待用户回答时间（毫秒）'"
				:required="true"
				:value="form.waitTime"
				@input="input"
				:videoIcon="aivideo"
				:showDetail="showDetail"
				:maxlength="7"
				prop="waitTime"
			/>
			<!-- 等待时长计算结果 -->
			<WaitTime v-if="getTalkId === 'collectShortVideo'" :value="form.waitTime" />
			<!-- 收集结果数据类型: 收音 || 信息收集 || 获取地理位置 -->
			<CollectionResultSelect
				v-if="hasCollectionResultSelect"
				:value="form.typeOfCollectedResults"
				:showDetail="showDetail"
				prop="typeOfCollectedResults"
				@input="input"
				@onAddVariable="onAddVariable"
			/>
			<!-- 多选框 -->
			<template v-if="hasMultipleSelect">
				<MultipleSelect
					v-if="getTalkId === 'messageSummary'"
					:label="'节点内容推送'"
					:options="getMessageSummarySource(taskId)"
					:notifyExternal="form.notifyExternal"
					:value="form.summary"
					:required="true"
					:showDetail="showDetail"
					:taskId="taskId"
					prop="summary"
					@input="input"
				/>
				<MultipleSelect
					@input="input"
					v-if="getTalkId === 'messageSummary'"
					:label="'变量推送'"
					:value="form.wordsVariable"
					:taskId="taskId"
					:notifyExternal="form.notifyExternal"
					:required="false"
					prop="wordsVariable"
				/>
			</template>
			<!-- 信息推送URL地址 -->
			<NormalInput
				v-if="getTalkId === 'messageSummary'"
				:variableIcon="false"
				:label="'信息推送URL地址'"
				placeholder="请输入信息汇总内容将要推送的URL地址"
				:required="false"
				:value="form.informationRushurlAddress"
				@input="input"
				:showDetail="showDetail"
				prop="informationRushurlAddress"
				@onAddVariable="onAddVariable"
				@showVideoTable="showVideoTable"
			/>
			<!-- 邀请三方-人工坐席工号 -->
			<template v-if="getTalkId === 'inviteHumanThreeParties'">
				<el-form-item label="派工方式">
					<el-radio-group v-model="form.inviteMode" size="medium">
						<el-radio-button label="none">不指定</el-radio-button>
						<el-radio-button label="agent">指定坐席</el-radio-button>
						<el-radio-button label="group">指定技能分组</el-radio-button>
					</el-radio-group>
				</el-form-item>

				<p v-if="form.inviteMode === 'agent'" class="label-gray">请设定被邀请的人工坐席：</p>
				<NormalInput
					v-if="form.inviteMode === 'agent'"
					:variableIcon="false"
					:label="'人工坐席工号'"
					placeholder="请输入对方坐席的工号，不填写默认盲转可用坐席"
					:required="false"
					:value="form.agentName"
					@input="input"
					:showDetail="showDetail"
					prop="agentName"
					:lableWidth="100"
					:error="agentNameError"
				/>
				<InterfaceListSelect
					v-if="form.inviteMode === 'group'"
					:required="false"
					:values="form.groups"
					prop="groups"
					typeSelect="skillGroup"
					@input="input"
					:showDetail="showDetail"
					@onChange="onChange"
					:bizSceneId="$route.query.bizscenariosId"
				/>
			</template>

			<!-- 邀请三方-通话模式 -->
			<p v-if="getTalkId === 'inviteHumanThreeParties'" class="label-gray">请选择三方加入会话后默认通话状态：</p>
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'inviteHumanThreeParties'"
				:required="true"
				:value="form.inviteMediaType"
				prop="inviteMediaType"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:listOptions="inviteMediaType"
			/>
			<!-- 邀请三方-麦克风状态 -->
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'inviteHumanThreeParties'"
				:required="true"
				:value="form.microphoneStatus"
				prop="microphoneStatus"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:listOptions="microphoneStatus"
			/>
			<!-- 调用方式状态 -->
			<InterfaceListSelect
				v-if="hasWordsInterfaceSelect && getTalkId === 'interfaceCall'"
				:required="true"
				:value="form.callMethod"
				prop="callMethod"
				:typeSelect="getTalkId"
				@input="input"
				:showDetail="showDetail"
				@onChange="onChange"
				:listOptions="callMethod"
			/>
			<!-- 智能问答模板 -->
			<AiProcessPeech
				v-if="hasAiProcessSpeech"
				:value="form.aiProcessSpeech"
				prop="aiProcessSpeech"
				:intelligentReply="form.intelligentReply"
				@input="input"
				:showDetail="showDetail"
				:nluError="nluError"
				@onSettingQuestion="onSettingQuestion"
				@onAddVariable="onAddVariable"
			/>
			<!-- 下一步操作 -->
			<NextStepTemplate
				v-if="hasNextStep"
				:value="form.nextStepYes"
				:nextStepOption="nextStepOption"
				@onChange="onChange"
				:showDetail="showDetail"
				prop="nextStepYes"
				:labelWidth="getTalkId === 'messageSummary' ? 120 : 100"
			/>
			<!-- 接口调用 => 请求参数小组件 RequestBody -->
			<interfaceCallRequestBody
				v-if="hasRequestApi && (form.callMethod === 'post' || form.callMethod === 'put' || form.callMethod === 'delete')"
				:showDetail="showDetail"
				:value="form.requestBody"
				prop="requestBody"
				@input="input"
				:taskId="taskId"
				:requestParametersError="requestParametersError"
			/>

			<!-- 接口调用 => 返回参数小组件 responseBody -->
			<interfaceCallResponseBody
				v-if="hasRequestApi && (form.callMethod === 'get' || form.callMethod === 'put' || form.callMethod === 'post')"
				:showDetail="showDetail"
				:value="form.responseBody"
				prop="responseBody"
				@input="input"
				:taskId="taskId"
				:returnParametersError="returnParametersError"
			/>

			<div class="inner-wraper" v-if="hiddenInnerContent">
				<!-- 意图库 -->
				<IntentLibary v-if="hasWordsIntention" :value="form.intentLib" :nluError="nluError" prop="intentLib" :showDetail="showDetail" @input="input" />
				<!-- ivvr 意图分支 -->
				<IvvrInput
					v-if="hasWordsIntention"
					:videoIcon="aivideo"
					:video="form.wordsNoAnswerVideo"
					:ivvrOptionsVideo="ivvrOptionsVideo"
					:showDetail="showDetail"
					:value="form.ivvrOptions"
					:nextStepOption="nextStepOption"
					:sureVideoData="sureVideoData"
					:nluError="nluError"
					@showVideoTable="showVideoTable"
					@input="input"
					prop="ivvrOptions"
				/>
				<!-- llm意图识别意图点 -->
				<LLM
					v-if="hasRecognizeFailed"
					:videoIcon="aivideo"
					:video="form.wordsNoAnswerVideo"
					:ivvrOptionsVideo="ivvrOptionsVideo"
					:showDetail="showDetail"
					:value="form.intentPoints"
					:nextStepOption="nextStepOption"
					:sureVideoData="sureVideoData"
					:nluError="nluError"
					@showVideoTable="showVideoTable"
					@input="input"
					prop="intentPoints"
				/>
				<!-- 选项判断添加选项 -->
				<OptionJudgeInput v-if="hasWordsOptionJudge" :nextStepOption="nextStepOption" :showDetail="showDetail" :value="form.judgeOptions" @input="input" prop="judgeOptions" />
				<!-- 肯定回答模板 || 提交成功-->
				<template v-if="hasWordsYes">
					<SettingLabel
						:label="getAnswerTitleLabel[0] ? getAnswerTitleLabel[0] : ''"
						:isSetting="getSettingVisiable"
						prop="answerYesData"
						@settingClick="settingClick('positive', 'answerYesData')"
					/>
					<AiSpeak
						v-if="!onlyHasNextStep && getTalkId !== 'soundReception' && getTalkId !== 'inviteHumanThreeParties' && getTalkId !== 'interfaceCall'"
						:variableIcon="true"
						:required="false"
						@clearVideo="clearVideo"
						:video="form.wordsYesVideo"
						:validateStatus="form.wordsYesVideoValidate"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsYes"
						@input="input"
						prop="wordsYes"
						:showDetail="showDetail"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
					/>
					<NextStepTemplate :showDetail="showDetail" :value="form.nextStepYes" :nextStepOption="nextStepOption" @onChange="onChange" prop="nextStepYes" />
				</template>
				<!-- 否定回答模板 || 提交失败 -->
				<template v-if="hasNextStepNo">
					<SettingLabel
						:label="getAnswerTitleLabel[1] ? getAnswerTitleLabel[1] : ''"
						:isSetting="getSettingVisiable"
						prop="answerNoData"
						@settingClick="settingClick('negative', 'answerNoData')"
					/>
					<AiSpeak
						v-if="!['inviteHumanThreeParties', 'startSystemRecording', 'stopSystemRecording'].includes(getTalkId)"
						:variableIcon="true"
						:required="false"
						:video="form.wordsNoVideo"
						:validateStatus="form.wordsNoVideoValidate"
						@clearVideo="clearVideo"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsNo"
						@input="input"
						:showDetail="showDetail"
						prop="wordsNo"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
					/>
					<NextStepTemplate :value="form.nextStepNo" :showDetail="showDetail" :nextStepOption="nextStepOption" @onChange="onChange" prop="nextStepNo" />
				</template>

				<!-- 没听清，请重复 -->
				<template v-if="hasRepeatWords">
					<HandlerEventLabel
						:label="'没听清请重复'"
						:isSetting="form.repeatSetting"
						@setSetting="status => setSetting('repeat', status)"
						@settingClick="settingClick('repeat', 'answerRepeatData')"
					/>
					<RepeatAndBlurTemplate
						v-if="form.repeatSetting"
						prop="repeatAnswers"
						:value="form.repeatAnswers"
						:nextStepOption="nextStepOption"
						:hasAiSpeakTextArea="hasAiSpeakTextArea"
						@input="input"
					/>
				</template>
				<!-- 嗯啊模糊回答 -->
				<template v-if="hasBlurWords">
					<HandlerEventLabel
						:label="'嗯啊模糊回答'"
						:isSetting="form.blurSetting"
						@setSetting="status => setSetting('blur', status)"
						@settingClick="settingClick('fuzzy', 'answerFuzzyData')"
					/>
					<RepeatAndBlurTemplate
						v-if="form.blurSetting"
						prop="blurAnswers"
						:value="form.blurAnswers"
						:nextStepOption="nextStepOption"
						:hasAiSpeakTextArea="hasAiSpeakTextArea"
						@input="input"
					/>
				</template>
				<!-- 其他回答模板 || 超时未提交-->
				<template v-if="hasWordsOther">
					<!-- 变量判断 动态添加变量条件-->
					<VariableJudgeInput
						v-if="hasWordsVariableJudge"
						:showDetail="showDetail"
						:value="form.variableJudgeOptions"
						:nextStepOption="nextStepOption"
						@input="input"
						prop="variableJudgeOptions"
					/>
					<!-- NLP对接 动态添加分支-->
					<NLPInput v-if="hasNlpBranch" :value="form.nlpOptions" prop="nlpOptions" @input="input" :showDetail="showDetail" />
					<SettingLabel :label="getAnswerTitleLabel[2] ? getAnswerTitleLabel[2] : ''" :isSetting="false" />
					<AiSpeak
						v-if="!hasInnerAiSpeakTextArea && !onlyHasNextStep && getTalkId !== 'soundReception' && getTalkId !== 'inviteHumanThreeParties' && getTalkId !== 'interfaceCall'"
						:variableIcon="true"
						:required="false"
						@clearVideo="clearVideo"
						:video="form.wordsOtherVideo"
						:validateStatus="form.wordsOtherVideoValidate"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsOther"
						@input="input"
						prop="wordsOther"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<!-- 文本框类型AI播报话术 -->
					<AiSpeak
						v-if="hasInnerAiSpeakTextArea"
						:label="'AI说'"
						placeholder="请输入AI客服播报的话术"
						:variableIcon="true"
						:value="form.wordsOther"
						:prop="'wordsOther'"
						@input="input"
						:textArea="hasAiSpeakTextArea"
						@clearVideo="clearVideo"
						:video="form.wordsOtherVideo"
						:validateStatus="form.wordsOtherVideoValidate"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<!-- 超时未提交等待时长输入框 -->
					<AiSpeak
						v-if="hasOtherWaitTime && getTalkId !== 'inviteHumanThreeParties'"
						:variableIcon="false"
						:label="'等待时长'"
						placeholder="请输入等待用户回答时间（毫秒）"
						:required="true"
						:value="form.wordsOverTime"
						@input="input"
						prop="wordsOverTime"
						:showDetail="showDetail"
						:maxlength="7"
					/>
					<AiSpeak
						v-if="hasConfidence"
						:label="'检测次数'"
						placeholder="最大允许检测的次数"
						:variableIcon="false"
						:required="true"
						:value="form.otherTimesMax"
						@input="input"
						prop="otherTimesMax"
						:showDetail="showDetail"
						:maxlength="2"
						:maxTips="false"
					/>
					<AiSpeak
						v-if="!hasConfidence && !onlyHasNextStep && getTalkId !== 'inviteHumanThreeParties'"
						:label="'最大允许次数'"
						:placeholder="getTalkId === 'interfaceCall' ? '允许调用失败的最大次数' : '请输入允许用户其他回答的最大次数'"
						:variableIcon="false"
						:required="true"
						:value="form.otherTimesMax"
						@input="input"
						prop="otherTimesMax"
						:showDetail="showDetail"
						:maxlength="2"
						:maxTips="true"
					/>

					<NextStepTemplate :showDetail="showDetail" :value="form.nextStepOther" :nextStepOption="nextStepOption" @onChange="onChange" prop="nextStepOther" />
					<AiSpeak
						v-if="!hasInnerAiSpeakTextArea && !onlyHasNextStep && getTalkId !== 'soundReception' && getTalkId !== 'inviteHumanThreeParties' && getTalkId !== 'interfaceCall'"
						:variableIcon="true"
						:required="false"
						:video="form.wordsEndVideo"
						:validateStatus="form.wordsEndVideoValidate"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsEnd"
						@input="input"
						prop="wordsEnd"
						@clearVideo="clearVideo"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<AiSpeak
						v-if="hasInnerAiSpeakTextArea"
						:textArea="hasAiSpeakTextArea"
						:label="'AI说'"
						:variableIcon="true"
						placeholder="请输入AI客服播报的话术"
						:value="form.wordsEnd"
						:prop="'wordsEnd'"
						@input="input"
						@clearVideo="clearVideo"
						:video="form.wordsEndVideo"
						:validateStatus="form.wordsEndVideoValidate"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
				</template>
				<!-- 不回答模板 -->
				<template v-if="hasWordsNoAnswer">
					<SettingLabel :label="getAnswerTitleLabel[3] ? getAnswerTitleLabel[3] : ''" :isSetting="false" />
					<AiSpeak
						v-if="!hasAiSpeakTextArea && getTalkId !== 'inviteHumanThreeParties'"
						:variableIcon="true"
						:required="false"
						:video="form.wordsNoAnswerVideo"
						:textArea="hasAiSpeakTextArea"
						:validateStatus="form.wordsNoAnswerVideoValidate"
						:value="form.wordsNoAnswer"
						@input="input"
						@clearVideo="clearVideo"
						prop="wordsNoAnswer"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<!-- 文本框类型AI播报话术 -->
					<AiSpeak
						v-else-if="getTalkId !== 'inviteLaborTripartite' && getTalkId !== 'inviteHumanThreeParties'"
						:label="'AI说'"
						:variableIcon="true"
						placeholder="请输入AI客服播报的话术"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsNoAnswer"
						:prop="'wordsNoAnswer'"
						@input="input"
						@clearVideo="clearVideo"
						:video="form.wordsNoAnswerVideo"
						:validateStatus="form.wordsNoAnswerVideoValidate"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<AiSpeak
						v-if="hasNoAnswerOverTime && getTalkId !== 'inviteHumanThreeParties'"
						:label="'等待时长'"
						placeholder="请输入等待用户回答时间（毫秒）"
						:variableIcon="false"
						:required="true"
						:value="form.noAnswerOverTime"
						@input="input"
						@onAddVariable="onAddVariable"
						prop="noAnswerOverTime"
						:showDetail="showDetail"
						:maxlength="7"
					/>
					<AiSpeak
						v-if="getTalkId !== 'inviteHumanThreeParties'"
						:label="'最大允许次数'"
						:placeholder="'请输入允许用户不回答的最大次数'"
						:variableIcon="false"
						:required="true"
						:value="form.noAnswerTimesMax"
						@input="input"
						@onAddVariable="onAddVariable"
						prop="noAnswerTimesMax"
						:showDetail="showDetail"
						:maxlength="2"
						:maxTips="true"
					/>

					<NextStepTemplate :showDetail="showDetail" :value="form.nextStepNoAnswer" :nextStepOption="nextStepOption" @onChange="onChange" prop="nextStepNoAnswer" />
					<AiSpeak
						v-if="!hasInnerAiSpeakTextArea && getTalkId !== 'inviteHumanThreeParties'"
						:variableIcon="true"
						:required="false"
						:video="form.wordsEndNoAnswerVideo"
						:textArea="hasAiSpeakTextArea"
						:validateStatus="form.wordsEndNoAnswerVideoValidate"
						@clearVideo="clearVideo"
						:value="form.wordsEndNoAnswer"
						@input="input"
						prop="wordsEndNoAnswer"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<AiSpeak
						v-else-if="getTalkId !== 'inviteLaborTripartite' && getTalkId !== 'inviteHumanThreeParties'"
						:label="'AI说'"
						:variableIcon="true"
						placeholder="请输入AI客服播报的话术"
						:textArea="hasAiSpeakTextArea"
						:value="form.wordsEndNoAnswer"
						:validateStatus="form.wordsEndNoAnswerVideoValidate"
						:prop="'wordsEndNoAnswer'"
						@input="input"
						:video="form.wordsEndNoAnswerVideo"
						@clearVideo="clearVideo"
						@showVideoTable="showVideoTable"
						@onAddVariable="onAddVariable"
						:showDetail="showDetail"
					/>
				</template>

				<!-- LLM识别失败 -->
				<template v-if="hasRecognizeFailed">
					<SettingLabel :label="getAnswerTitleLabel[4] ? getAnswerTitleLabel[4] : ''" :isSetting="false" />
					<AiSpeak
						:label="'最大允许次数'"
						:placeholder="'请输入允许用户识别的最大次数'"
						:variableIcon="false"
						:required="true"
						:value="form.llmRecognizeTimesMax"
						@input="input"
						@onAddVariable="onAddVariable"
						prop="llmRecognizeTimesMax"
						:showDetail="showDetail"
						:maxlength="2"
						:maxTips="true"
					/>

					<NextStepTemplate :showDetail="showDetail" :value="form.llmRecognizeNextStep" :nextStepOption="nextStepOption" @onChange="onChange" prop="llmRecognizeNextStep" />
				</template>

				<!-- 识别结果模板 -->
				<template v-if="hasResultFailed && form.openOCR">
					<SettingLabel :label="getAnswerTitleLabel[4] ? getAnswerTitleLabel[4] : ''" :isSetting="false" />
					<AiSpeak
						v-if="!hasAiSpeakTextArea"
						:variableIcon="true"
						:required="false"
						:video="form.resultFailedSpeakVideo"
						:textArea="hasAiSpeakTextArea"
						:validateStatus="form.resultFailedSpeakVideoValidate"
						:value="form.resultFailedSpeak"
						@input="input"
						@clearVideo="clearVideo"
						prop="resultFailedSpeak"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<!-- 文本框类型AI播报话术 -->
					<AiSpeak
						v-else-if="getTalkId !== 'inviteLaborTripartite' && getTalkId !== 'inviteHumanThreeParties'"
						:label="'AI说'"
						:variableIcon="true"
						placeholder="请输入AI客服播报的话术"
						:textArea="hasAiSpeakTextArea"
						:value="form.resultFailedSpeak"
						:prop="'wordsNoAnswer'"
						@input="input"
						@clearVideo="clearVideo"
						:video="form.resultFailedSpeakVideo"
						:validateStatus="form.resultFailedSpeakVideoValidate"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<AiSpeak
						v-if="resultFailedWaitTimes && getTalkId !== 'inviteHumanThreeParties'"
						:label="'等待时长'"
						placeholder="请输入等待用户回答时间（毫秒）"
						:variableIcon="false"
						:required="true"
						:value="form.resultFailedWaitTimes"
						@input="input"
						@onAddVariable="onAddVariable"
						prop="resultFailedWaitTimes"
						:showDetail="showDetail"
						:maxlength="7"
					/>
					<AiSpeak
						:label="'识别次数'"
						:placeholder="'请输入允许用户识别的最大次数'"
						:variableIcon="false"
						:required="true"
						:value="form.resultFailedTimesMax"
						@input="input"
						@onAddVariable="onAddVariable"
						prop="resultFailedTimesMax"
						:showDetail="showDetail"
						:maxlength="2"
						:maxTips="true"
					/>

					<NextStepTemplate :showDetail="showDetail" :value="form.resultFailedNextStep" :nextStepOption="nextStepOption" @onChange="onChange" prop="resultFailedNextStep" />
					<AiSpeak
						v-if="!hasInnerAiSpeakTextArea && getTalkId !== 'inviteHumanThreeParties'"
						:variableIcon="true"
						:required="false"
						:video="form.resultFailedNextStepSpeakVideo"
						:textArea="hasAiSpeakTextArea"
						:validateStatus="form.resultFailedNextStepSpeakVideoValidate"
						@clearVideo="clearVideo"
						:value="form.resultFailedNextStepSpeak"
						@input="input"
						prop="resultFailedNextStepSpeak"
						@onAddVariable="onAddVariable"
						@showVideoTable="showVideoTable"
						:showDetail="showDetail"
					/>
					<AiSpeak
						v-else-if="getTalkId !== 'inviteLaborTripartite' && getTalkId !== 'inviteHumanThreeParties'"
						:label="'AI说'"
						:variableIcon="true"
						placeholder="请输入AI客服播报的话术"
						:textArea="hasAiSpeakTextArea"
						:value="form.resultFailedNextStepSpeak"
						:validateStatus="form.resultFailedNextStepSpeakVideoValidate"
						:prop="'resultFailedNextStepSpeak'"
						@input="input"
						:video="form.resultFailedNextStepSpeakVideo"
						@clearVideo="clearVideo"
						@showVideoTable="showVideoTable"
						@onAddVariable="onAddVariable"
						:showDetail="showDetail"
					/>
				</template>
			</div>

			<!-- 挂断模板 -->
			<template v-if="hasEndTemplate">
				<NormalInput
					:variableIcon="false"
					:showDetail="true"
					:label="'下一步'"
					:required="false"
					:value="getTalkId === 'transfer' ? '转接给人工客服' : '挂断通话'"
					@input="input"
					:video="null"
					:taskId="taskId"
					prop=""
					:readonly="true"
					@onAddVariable="onAddVariable"
					@showVideoTable="showVideoTable"
					style="pointer-events: none"
					v-if="getTalkId !== 'sceneTransfer'"
				/>
				<EndTemplate
					:value="form.hangupReason"
					:showDetail="showDetail"
					:label="'挂断原因'"
					:isCompleted="form.isCompleted"
					@input="input"
					:prop="'hangupReason'"
					v-if="getTalkId === 'hangup'"
					:placeholder="'请输入挂断原因'"
				/>
				<InterfaceListSelect
					v-if="getTalkId === 'transfer'"
					:required="false"
					:values="form.transferGroups"
					prop="transferGroups"
					typeSelect="skillGroup"
					@input="input"
					:showDetail="showDetail"
					@onChange="onChange"
					:bizSceneId="$route.query.bizscenariosId"
				/>
				<EndTemplate
					:label="'转人工原因'"
					:placeholder="'请输入转人工原因'"
					:value="form.transferReason"
					:showDetail="showDetail"
					:isCompleted="form.isCompleted"
					@input="input"
					:prop="'transferReason'"
					v-if="getTalkId === 'transfer'"
				/>
				<EndTemplate
					:label="'转人工原因'"
					:placeholder="'请输入转人工原因'"
					:value="form.transferReason"
					:showDetail="showDetail"
					:isCompleted="form.isCompleted"
					@input="input"
					:prop="'transferReason'"
					v-if="getTalkId === 'sceneTransfer'"
					:hideInput="true"
				/>
			</template>
		</el-form>
	</div>
</template>

<script>
import AiSpeak from '../AiSpeak/index.vue';
import EndTemplate from './EndTemplate.vue';
import SettingLabel from './SettingLabel.vue';
import AiProcessPeech from './AiProcessPeech.vue';
import NextStepTemplate from './NextStepTemplate.vue';
import HandlerEventLabel from './HandlerEventLabel.vue';

import RepeatAndBlurTemplate from './RepeatAndBlurTemplate.vue';

import BusinessInstruct from './BusinessInstruct.vue';
import CollectVariableSelect from './CollectVariableSelect.vue';
import IvvrInput from './IvvrInput.vue';
import LLM from './LLM.vue';
import InterfaceListSelect from './InterfaceListSelect.vue';
import VariableJudgeInput from './VariableJudgeInput.vue';
import CollectionResultSelect from './CollectionResultSelect.vue';
import MultipleSelect from './MultipleSelect.vue';
import NormalInput from './NormalInput.vue';
import OptionJudgeInput from './OptionJudgeInput.vue';
import SendContentsInput from './SendContentsInput.vue';
import NLPInput from './NLPInput.vue';
import IntentLibary from './IntentLibary.vue';
import WaitTime from './WaitTime.vue';
import interfaceCallResponseBody from './interfaceCallResponseBody.vue';
import interfaceCallRequestBody from './interfaceCallRequestBody.vue';
import CardCollection from './CardCollectionCompoents/CardCollection.vue';

import AIWorkflow from '@/modules/workFlow';
import { mapGetters, mapState } from 'vuex';

export default {
	props: {
		variableIcon: {
			type: Boolean,
			default: () => true
		},
		taskId: {
			type: String,
			default: () => '',
			required: true
		},
		nextStepOption: {
			type: Array,
			default: () => []
		},
		form: {
			type: Object,
			required: true,
			default: () => {}
		},
		agentNameError: {
			type: String,
			default: () => ''
		},
		nluError: {
			type: Boolean,
			default: () => false
		},
		returnParametersError: {
			type: Boolean,
			default: () => false
		},
		requestParametersError: {
			type: Boolean,
			default: () => false
		},
		showDetail: {
			type: Boolean,
			default: () => false
		}
	},

	computed: {
		...mapState('workflow', ['worksteps']),
		...mapGetters('workflow', ['messageSummarySource']),
		getMessageSummarySource() {
			return talkId => {
				return AIWorkflow.setMessageSummarySource(talkId);
			};
		},
		hasAiSpeak() {
			return AIWorkflow.hasAiSpeak(this.taskId);
		},
		hasWordsYes() {
			return AIWorkflow.hasWordsYes(this.taskId);
		},
		hasWaitTime() {
			return AIWorkflow.hasWaitTime(this.taskId);
		},
		hasConfidence() {
			return AIWorkflow.hasConfidence(this.taskId);
		},

		hasNextStep() {
			return AIWorkflow.hasNextStep(this.taskId);
		},
		hasNextStepNo() {
			return AIWorkflow.hasNextStepNo(this.taskId);
		},
		hasWordsOther() {
			return AIWorkflow.hasWordsOther(this.taskId);
		},
		hasWordsNoAnswer() {
			return AIWorkflow.hasWordsNoAnswer(this.taskId);
		},

		hasRecognizeFailed() {
			return AIWorkflow.hasRecognizeFailed(this.taskId);
		},
		hasResultFailed() {
			return AIWorkflow.hasResultFailed(this.taskId);
		},
		hasAiSpeakTextArea() {
			return AIWorkflow.hasAiSpeakTextArea(this.taskId);
		},
		hasEndTemplate() {
			return AIWorkflow.hasEndTemplate(this.taskId);
		},
		hasAiProcessSpeech() {
			// 实时拟合模式下，支持智能问答
			const { videoType } = AIWorkflow.getRobotProperty();
			return AIWorkflow.hasAiProcessSpeech(this.taskId) && videoType === 'real-time-fitting';
		},
		hasWordsIntention() {
			return AIWorkflow.hasWordsIntention(this.taskId);
		},
		hasWordsVariableJudge() {
			return AIWorkflow.hasWordsVariableJudge(this.taskId);
		},
		hasWordsInterfaceSelect() {
			return AIWorkflow.hasWordsInterfaceSelect(this.taskId);
		},
		hasWordsVariable() {
			return AIWorkflow.hasWordsVariable(this.taskId);
		},
		getAnswerTitleLabel() {
			return AIWorkflow.getAnswerTitleLabel(this.taskId);
		},
		getSettingVisiable() {
			return AIWorkflow.getSettingVisiable(this.taskId);
		},
		hasOtherWaitTime() {
			return AIWorkflow.hasOtherWaitTime(this.taskId);
		},
		hasCollectionResultSelect() {
			return AIWorkflow.hasCollectionResultSelect(this.taskId);
		},

		hiddenInnerContent() {
			const id = AIWorkflow.getTalkId(this.taskId);
			return ['hangup', 'speakWaiting', 'sendMessage', 'transfer', 'sceneTransfer', 'silentWating', 'messageSummary', 'sendContents'].indexOf(id) === -1;
		},

		onlyHasNextStep() {
			const id = AIWorkflow.getTalkId(this.taskId);
			return ['optionJudge', 'variableJudge', 'startSystemRecording', 'stopSystemRecording'].indexOf(id) !== -1;
		},

		hasInnerAiSpeakTextArea() {
			const id = AIWorkflow.getTalkId(this.taskId);
			return ['ivvr'].indexOf(id) !== -1;
		},
		hasBusinessInstruct() {
			return AIWorkflow.hasBusinessInstruct(this.taskId);
		},
		hasMultipleSelect() {
			return AIWorkflow.hasMultipleSelect(this.taskId);
		},

		getTalkId() {
			return AIWorkflow.getTalkId(this.taskId);
		},
		hasWordsOptionJudge() {
			return AIWorkflow.hasWordsOptionJudge(this.taskId);
		},
		hasWordsSendContents() {
			return AIWorkflow.hasWordsSendContents(this.taskId);
		},
		hasNlpBranch() {
			return AIWorkflow.hasNlpBranch(this.taskId);
		},
		hasNoAnswerOverTime() {
			return AIWorkflow.hasNoAnswerOverTime(this.taskId);
		},
		hasAiSpeakRequired() {
			return AIWorkflow.getTalkId(this.taskId) !== 'messageCollect';
		},
		hasRepeatWords() {
			return AIWorkflow.hasRepeatWords(this.taskId);
		},
		hasBlurWords() {
			return AIWorkflow.hasBlurWords(this.taskId);
		},
		hasRequestApi() {
			return AIWorkflow.hasRequestApi(this.taskId);
		},
		getDefaultCardCollectionOptions() {
			return () => AIWorkflow.getDefaultCardCollectionOptions() || [];
		}
	},
	components: {
		AiSpeak,
		NextStepTemplate,
		AiProcessPeech,
		SettingLabel,
		CollectVariableSelect,
		IvvrInput,
		InterfaceListSelect,
		VariableJudgeInput,
		CollectionResultSelect,
		BusinessInstruct,
		MultipleSelect,
		NormalInput,
		OptionJudgeInput,
		SendContentsInput,
		NLPInput,
		IntentLibary,
		EndTemplate,
		WaitTime,
		RepeatAndBlurTemplate,
		HandlerEventLabel,
		interfaceCallResponseBody,
		interfaceCallRequestBody,
		CardCollection,
		LLM
	},

	watch: {
		taskId(valNew, valOld) {
			if (valNew !== valOld) {
				this.isTaskIdChange = true;
				this.$nextTick(() => {
					this.$refs['template']?.resetFields();
					this.isTaskIdChange = false;
				});
			}
		}
	},

	mounted() {
		const { videoType, audioType } = AIWorkflow.getRobotProperty();
		this.videoType = videoType;
		this.audioType = audioType;
		this.$nextTick(() => {
			this.$refs['template'].resetFields();
		});
	},
	data() {
		return {
			videoType: '',
			audioType: '',
			rules: AIWorkflow.getTemplateValidateRules(this.taskId),
			// 邀请三方
			inviteMediaType: [
				{ label: '语音', type: 'audio' },
				{ label: '视频', type: 'video' }
			], // 语音还是视频 audio | video
			microphoneStatus: [
				{ label: '开麦', type: 'unmute' },
				{ label: '静音', type: 'mute' }
			], // 开麦还是静音 mute | unmute
			collectShortVideoTimes: [
				{ label: '30秒', time: 30000 },
				{ label: '1分钟', time: 60000 },
				{ label: '1.5分钟', time: 90000 },
				{ label: '2分钟', time: 120000 },
				{ label: '3分钟', time: 180000 },
				{ label: '4分钟', time: 240000 },
				{ label: '5分钟', time: 300000 },
				{ label: '10分钟', time: 600000 }
			], // 采集时长

			repeatSetting: false, // 重复回答输入框显示隐藏
			blurSetting: false, // 模糊回答输入框显示隐藏
			// 调用方式
			callMethod: [
				{ label: 'get', value: 'get' },
				{ label: 'post', value: 'post' },
				{ label: 'delete', value: 'delete' },
				{ label: 'put', value: 'put' }
			],
			isTaskIdChange: false
		};
	},

	methods: {
		input(prop, e) {
			console.log(prop, 'TemplateForm：input', e);
			this.$emit('input', prop, e);
		},

		onChange(prop, e) {
			// console.log(prop, 'TemplateForm：onChange', e);
			this.$emit('onChange', prop, e);
		},
		onAddVariable(val, data) {
			this.$emit('onAddVariable', val, data);
		},

		clearVideo(prop) {
			this.$emit('clearVideo', prop);
		},
		showVideoTable(data) {
			this.$emit('showVideoTable', data);
		},
		settingClick(type, prop) {
			this.$emit('settingClick', type, prop);
		},
		onSettingQuestion() {
			this.$emit('onSettingQuestion');
		},
		chooseUserAttribute(prop, data, businessData) {
			this.$emit('chooseUserAttribute', prop, data, businessData);
		},
		setSetting(prop, status) {
			if (prop === 'blur') {
				this.blurSetting = status;
				this.$emit('input', 'blurSetting', status);
				if (!status) {
					this.$emit('input', 'blurAnswers', [
						{
							words: null,
							wordsVideo: null,
							wordsVariableId: null,
							wordsVariables: [],
							wordsVideoValidate: true,
							wordsEndVariableId: null,
							wordsEndVariables: [],
							wordsTimesMax: null,
							nextStep: null,
							wordsEnd: null,
							wordsEndVideo: null,
							wordsEndVideoValidate: true
						}
					]);
					this.$emit('input', 'answerFuzzyData', {
						keys: [],
						isAnswerNluLib: true,
						isOtherNluLib: false,
						nluMark: 'fuzzy'
					});
					// this.$nextTick(() => {
					// 	this.$refs['template'].resetFields();
					// });
				}
			} else {
				this.repeatSetting = status;
				this.$emit('input', 'repeatSetting', status);
				if (!status) {
					this.$emit('input', 'repeatAnswers', [
						{
							words: null,
							wordsVideo: null,
							wordsVariableId: null,
							wordsVariables: [],
							wordsVideoValidate: true,
							wordsEndVariableId: null,
							wordsEndVariables: [],
							wordsTimesMax: null,
							nextStep: null,
							wordsEnd: null,
							wordsEndVideo: null,
							wordsEndVideoValidate: true
						}
					]);
					this.$emit('input', 'answerRepeatData', {
						keys: [],
						isAnswerNluLib: true,
						isOtherNluLib: false,
						nluMark: 'repeat'
					});
					// this.$nextTick(() => {
					// 	this.$refs['template'].resetFields();
					// });
				}
			}
		}
		// getInviteMode() {
		// 	if (this.taskId.includes('inviteHumanThreeParties')) {
		// 		console.log('getInviteMode', this.form, this.taskId);
		// 		return this.form.agentName ? 'agent' : this.form.groups?.length > 0 ? 'group' :'none';
		// 	}
		// 	return 'none';
		// }
	}
};
</script>

<style lang="less">
@import '../styles/index.less';
</style>

<style lang="less" scoped>
.ai-template-form-wrapper {
	overflow-x: hidden;
}
</style>
